#!/bin/bash
nginxurl=/opt/openresty/nginx
. $nginxurl/scripts/golo.conf
cd  $ASLAM_WS_PATH/../map/network_data
aslam_pcd=$(du  *.pcd |sort -nr |sed -n '1p' |awk -F " " '{print $2}')
if [ $1 == map_full ];then
   sudo mv $ASLAM_WS_PATH/../map/network_data/$aslam_pcd  $ASLAM_WS_PATH/../map/network_data/map_3d.pcd
fi
if [ $1 == map_3d ];then
   sudo mv $ASLAM_WS_PATH/../map/network_data/$aslam_pcd  $ASLAM_WS_PATH/../map/network_data/map_full.pcd; sudo cp $ASLAM_WS_PATH/../map/network_data/2024.pcd  $ASLAM_WS_PATH/../map/network_data/map_3d.pcd
fi
cd $ASLAM_WS_PATH/auto_driving_perception/lidar_slam/yaml
aslam_method=$( cat method.yaml |grep self_align_method |awk -F ":" '{print $2}'|awk -F "#" '{print $1}')
sed -i "s/$aslam_method/ $2 /g" method.yaml
aslam_mapfilter=$( cat method.yaml |grep local_map_filter |sed -n '2p'|awk -F ":" '{print $2}'|awk -F "#" '{print $1}')
sed -i "41s/$aslam_mapfilter/ $3 /g" method.yaml
if [ $3 == voxel_filter ];then
aslam_vxleaf_size=$( cat point_cloud_filter.yaml |grep leaf_size |sed -n '3p'|awk -F "[" '{print $2}'|awk -F "]" '{print $1}')
sed -i "12s/$aslam_vxleaf_size/$4/g" point_cloud_filter.yaml
fi
sudo systemctl restart aslamM.service ;rosnode kill /mapping_node;echo y |rosnode cleanup
